package dao

import (
	"zg3yk/inits"
	"zg3yk/model"
)

func CreateMessage(formUserId int, ToUserId int, message string) bool {
	var max1 = formUserId
	var min1 = ToUserId
	if formUserId < ToUserId {
		min1 = formUserId
		max1 = ToUserId
	}
	result := &model.Message{
		FormUserId: formUserId,
		ToUserId:   ToUserId,
		Message:    message,
		RoomId:     min1*10000 + max1,
	}
	if inits.DB.Create(&result).Error != nil {
		return false
	}
	return true
}
